#!/bin/bash
trap 'echo Abort ; exit 1' ERR
err() { echo Error, $@ not found. ; exit 1; }

echo Make root file system skeleton.
SRC=/opt/9263/toolchain/
[ ! -d $SRC ] && err $SRC
[ ! -d /opt/9263/kernelmodules ] && err /opt/9263/kernelmodules
[ ! -d /opt/9263/rootfs ] && mkdir /opt/9263/rootfs
[ `ls /opt/9263/rootfs/ -a | wc -l` -ne 2 ] && { echo /opt/9263/rootfs not empty. Abort. ; exit 1 ; }
pushd /opt/9263/rootfs
mkdir -p etc/init.d bin sbin usr/bin usr/include proc sys dev root home tmp
cp -a /opt/9263/kernelmodules/lib .
cp -a $SRC/lib .
cp -a $SRC/usr/lib usr/
cp -a $SRC/usr/arm-none-linux-gnueabi/lib usr/
popd
